<template>
  <div>
    <div class="right">
      <a href="javascript:void (0)" v-routers="{path:'/'}"></a>
    </div>
    <div class="card">
      <el-button class="defaultBtn" icon="el-icon-plus" @click="dialogVisibleClass=true" type="info">新增</el-button>
    </div>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="name" label="菜单名称" min-width="180"></el-table-column>
      <el-table-column prop="class" label="路径名称" min-width="180"></el-table-column>
      <el-table-column prop="type" label="是否显示" min-width="180"><template #default="{row}">{{type(row)}}</template></el-table-column>
      <el-table-column prop="type" label="菜单权限" min-width="180">
        <template #default="{row}">学生｜老师</template>
      </el-table-column>
      <el-table-column prop="crateTime" label="创建时间" min-width="180"></el-table-column>
      <el-table-column fixed="right" align="center" label="操作" width="180">
        <el-button size="mini" class="defaultBtn" type="info">删除</el-button>
        <el-button size="mini" class="defaultBtn" @click="dialogVisibleClass=true" type="info">编辑</el-button>
      </el-table-column>
    </el-table>


    <el-dialog title="菜单管理" :visible.sync="dialogVisibleClass" width="600px" :before-close="handleCloseClass">
      <el-form ref="form" :model="form" label-width="80px" >
        <el-form-item label="菜单名称">
          <el-input v-model="form.name" placeholder="请输入菜单名称"></el-input>
        </el-form-item>
        <el-form-item label="菜单路径">
          <el-input v-model="form.name" placeholder="请输入路径"></el-input>
        </el-form-item>
        <el-form-item label="用户权限">
          <el-checkbox-group v-model="form.type">
            <el-checkbox label="0" name="type">学生</el-checkbox>
            <el-checkbox label="1" name="type">老师</el-checkbox>
            <el-checkbox label="2" name="type">辅导员</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="菜单状态">
          <el-radio-group v-model="form.resource">
            <el-radio :label="0">启用</el-radio>
            <el-radio :label="1">禁用</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleClass = false">取 消</el-button>
        <el-button type="info" class="defaultBtn" @click="dialogVisibleClass = false">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisibleClass:false,
      tableData: [{name:'首页菜单',class:'/student',major:'计算机科学与网络',type:0,crateTime:'2022-12-31 12:00:00'}],
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: 0,
        desc: ''
      }
    }
  },
  methods:{
    type(item){
      console.log(item)
      switch (item.type){
        case 0:{
          return '不显示'
        }
        case 1:{
          return  '显示'
        }
      }
    },
    handleCloseClass(){
      this.dialogVisibleClass=false
    }
  }
}
</script>

<style scoped lang="scss">

.card{
  width: 100%;
  margin: 10px 0;
}
.page{
  width: 100%;
  display: flex;
  justify-content: right;
  margin-top: 10px;
}
::v-deep(.el-pagination.is-background .el-pager li:not(.disabled).active ){
  background: #333 !important;
  color: #fff;
}
</style>
